from pyecharts.charts import Map
from pyecharts import options as opts

# 数据准备
data = [
    ("北京", 100),
    ("天津", 100),
    ("河北", 100),
    ("山西", 100),
    ("内蒙古", 100),
    ("辽宁", 100),
    ("吉林", 100),
    ("黑龙江", 100),
    ("上海", 100),
    ("江苏", 100),
    ("浙江", 100),
    ("安徽", 100),
    ("福建", 100),
    ("江西", 100),
    ("山东", 100),
    ("河南", 100),
    ("湖北", 100),
    ("湖南", 100),
    ("广东", 100),
    ("广西", 100),
    ("海南", 100),
    ("重庆", 100),
    ("四川", 100),
    ("贵州", 100),
    ("云南", 100),
    ("西藏", 100),
    ("陕西", 100),
    ("甘肃", 100),
    ("青海", 100),
    ("宁夏", 100),
    ("新疆", 100),
    ("香港", 100),
    ("澳门", 100),
    ("台湾", 100),
    ("南海诸岛", 100)
]

# 创建地图
map_chart = (
    Map()
    .add("用户访问量", data, "china")
    .set_global_opts(
        title_opts=opts.TitleOpts(title="中国地图 - 用户访问量分布"),
        visualmap_opts=opts.VisualMapOpts(min_=50, max_=200)
    )
)

# 渲染地图
map_chart.render("china.html")
